{% extends 'blog/backend/backend_base.html' %}

{% block backendcontent %}
    {% load static category %}
    <style>
        .CSS5-left {
            float: left;
            margin: auto;
        }
    </style>
    <div>
        <p>添加文章</p>
        <form action="/add_article/" method="post">
            {% csrf_token %}
            <div class="form-group">
                <label for="id_name">
                    文章标题
                </label>
                <input type="text" id="id_name" name="title" class="form-control">
                <p>内容（kindeditor富文本编辑器，已支持上传图片）</p>
                <textarea id="editor_id" name="text_content" style="width:100%;height:500px;">&lt;strong&gt;HTML内容&lt;/strong&gt;</textarea>
                <div class="container">
                    <div class="row">
                        <div>分类信息</div>
                        {% get_category_list as category_list %}
                        {% for category in category_list %}
                            <div class="col-md-2">
                                <tr>
                                    <td>{{ category.id }}</td>
                                    <td>
                                        <input type="checkbox" name="category_id" value="{{ category.id }}">
                                        <a>{{ category.name }}</a>
                                    </td>
                                </tr>
                            </div>
                        {% endfor %}

                    </div>
                    <div class="row">
                        <div>标签信息</div>
                        {% get_tag_list as tag_list %}
                        {% for tag_index in tag_list %}
                            <div class="col-md-3">
                                <tr>
                                    <td>{{ tag_index.id }}</td>
                                    <td>
                                        <input type="checkbox" name="tag_id" value="{{ tag_index.id }}">
                                        <a>{{ tag_index.name }}</a>
                                    </td>
                                </tr>
                            </div>
                        {% endfor %}
                    </div>
                </div>
                <p>
                    <button class="btn btn-success">提交</button>
                </p>
            </div>
        </form>

        <link rel="stylesheet" href="{% static 'backend/kindeditor/themes/default/default.css' %}"/>
        <script charset="utf-8" src="{% static 'backend/kindeditor/kindeditor-all.js' %}"></script>
        <script charset="utf-8" src="{% static 'backend/kindeditor/lang/zh-CN.js' %}"></script>
        <script>
            KindEditor.ready(function (K) {
                window.editor = K.create('#editor_id', {
                    uploadJson: '/kindeditor_upload_img/',
                });
            });

        </script>

    </div>
{% endblock backendcontent %}